﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Results;
using wps_demo.Models;
using wps_demo.Utils;

namespace wps_demo.Controller
{
    public class WPSUserController : ApiController
    {
        [HttpPost,Route("v1/3rd/user/info")]
        public JsonResult<JObject> UserInfo() {
            LogHelper.Info("进入v1/3rd/user/info");
            JObject jsonObject = new JObject();
            JArray jsonArray = new JArray();
            JObject user = new JObject();
            WPS_User userModel = new WPS_User();
            try {
                user.Add("id", userModel.ID);
                user.Add("name", userModel.NAME);
                user.Add("permission", userModel.PERMISSION);
                user.Add("avatar_url", userModel.AVATAR_URL);
                jsonArray.Add(user);
                jsonObject.Add("users", jsonArray);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            LogHelper.Info("users："+ jsonObject.ToString());
            LogHelper.Info("离开v1/3rd/user/info");
            return Json(jsonObject);
        }
    }
}
